-
Notifications
You must be signed in to change notification settings - Fork 121
[Woo POS] Coupons: Show an error and CTA to proceed without Coupons - Dummy UI #15420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Woo POS] Coupons: Show an error and CTA to proceed without Coupons - Dummy UI #15420
Conversation
With this commit the functionality doesn't change - PointOfSaleOrderSyncErrorMessageView is presented with an error that is returned by the API. However, now we can distinguish between coupon and other errors.
…etpack-connected sites
Show PointOfSaleOrderSyncCouponsErrorMessageView when invalidCoupons error happens during Order creation. Remove coupons from cart before retrying.
|
|
iamgabrielma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great! 🚢
Self-hosted
🔵 Tracked pos_order_creation_failed, properties: [error_description: The operation couldn’t be completed. (Networking.NetworkError error 2.), was_ecommerce_trial: false, plan: , site_url: https://indiemelon.mystagingwebsite.com, blog_id: -1, store_id: c5bd46cc-1804-4f7b-badb-bb98c449127f, is_wpcom_store: false, error_context: Sorry, there was an issue with the server. Please try again later. (Error code: 400). Response: {"code":"woocommerce_rest_invalid_coupon","message":"Coupon \"invalid_coupon\" does not exist!","data":{"status":400}}, use_gift_card: false]
Then:
🔵 Tracked pos_order_creation_success, properties: [store_id: c5bd46cc-1804-4f7b-badb-bb98c449127f, was_ecommerce_trial: false, is_wpcom_store: false, plan: , site_url: https://indiemelon.mystagingwebsite.com, blog_id: -1]
Dotcom:
🔵 Tracked pos_order_creation_failed, properties: [site_url: https://indiemelon.mystagingwebsite.com, use_gift_card: false, is_wpcom_store: false, error_description: The operation couldn’t be completed. (Networking.DotcomError error 0.), blog_id: 215063064, error_context: Dotcom Error: [woocommerce_rest_invalid_coupon] Coupon "invalid_coupon" does not exist!, plan: jetpack_security_daily, store_id: c5bd46cc-1804-4f7b-badb-bb98c449127f, was_ecommerce_trial: false]
then
🔵 Tracked pos_order_creation_success, properties: [was_ecommerce_trial: false, blog_id: 215063064, is_wpcom_store: false, store_id: c5bd46cc-1804-4f7b-badb-bb98c449127f, plan: jetpack_security_daily, site_url: https://indiemelon.mystagingwebsite.com]
| data: data, | ||
| options: [.documentType: NSAttributedString.DocumentType.html], | ||
| documentAttributes: nil) { | ||
| var attributedString = AttributedString(nsAttributedString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL we can also attempt to parse this to markdown via try AttributedString(markdown: message) (need to import Foundation). Maybe would be cleaner than using NSAttributedString, or we could keep both as a fallback if the initial decoding fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll try 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it doesn't parse through all the HTML tags. I tried different options but it didn't work.
| // MARK: - TODO when copy is finalized | ||
| // | ||
| //private extension PointOfSaleOrderSyncErrorMessageView { | ||
| // enum Localization { | ||
| // static let title = NSLocalizedString( | ||
| // "pointOfSale.orderSync.couponsError.title", | ||
| // value: "Invalid coupons", | ||
| // comment: "Title of the error when failing to validate coupons and calculate order totals" | ||
| // ) | ||
| // | ||
| // static let actionTitle = NSLocalizedString( | ||
| // "pointOfSale.orderSync.couponsError.proceed", | ||
| // value: "Continue without coupons", | ||
| // comment: "Button title to remove coupons and retry synchronizing order and calculating order totals" | ||
| // ) | ||
| // } | ||
| //} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a follow-up somewhere and a link here so we don't forget :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Okay, I will. All these PRs are with dummy UI so we'll need to do a second round to create a proper look,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Created a task [Woo POS] Coupons: Checkout - Error Handling (Designer UI) #15424
- Added a comment 6376ff7
Closes: #15403
Description
Show an error and CTA to proceed without Coupons.
Solution
orderStateerror set inPointOfSaleOrderControllerto be more versatile and allow expansion to specific error casesinvalidCouponerror stateCouponErrorto distinguish coupon errors both for self-hosted and Dotcom loginsPointOfSaleOrderSyncCouponsErrorMessageViewwith dummy UI and ability to remove coupons before retrying order creationPointOfSaleOrderSyncCouponsErrorMessageViewparses HTML error since sometimes coupons errors arrive with HTML tagsSteps to reproduce
Before testing, update addToCart method in
PointOfSaleAggregateModelto add an invalid coupon with an item, for example:Test with both Dotcom and Self-hosted login:
Testing information
Screenshots
Simulator.Screen.Recording.-.iPad.Air.11-inch.M2.-.2025-03-25.at.15.46.47.mp4
RELEASE-NOTES.txtif necessary.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: